/*
 * $Id$
 *
 * Copyright 2008 HuangHuang. All rights reserved.
 */
package com.crm.service.impl;

import com.crm.service.IListboxService;
import com.crm.model.Listbox;
import com.crm.dao.IListboxDao;
import com.crm.dao.ICustomerDao;

import java.util.List;

/**
 * @author <a href="mailto:huang0510@hotmail.com">HuangHuang</a>
 * @version $Id$
 */
public class ListboxService implements IListboxService {

    private IListboxDao listboxDao;
    private ICustomerDao customerDao;

    public void setListboxDao(IListboxDao listboxDao) {
        this.listboxDao = listboxDao;
    }

    public void setCustomerDao(ICustomerDao customerDao) {
        this.customerDao = customerDao;
    }

    /**
     * {@inheritDoc}
     */
    public List<Listbox> getList(String listboxName) {
        return listboxDao.getList(listboxName);
    }

    /**
     * {@inheritDoc}
     */
    public void create(Listbox listbox) {
        listboxDao.saveOrUpdate(listbox);
    }

    /**
     * {@inheritDoc}
     */
    public void create(String className, String listName) throws Exception {
        Listbox list = (Listbox) Class.forName(className).newInstance();
        list.setName(listName);
        listboxDao.saveOrUpdate(list);
    }

    /**
     * {@inheritDoc}
     */
    public void update(Listbox listbox) {
        listboxDao.saveOrUpdate(listbox);
    }

    /**
     * {@inheritDoc}
     */
    public void delete(Listbox listbox) throws Exception{
        listboxDao.delete(listbox);
    }
}
